package com.chem.search.config;

import com.chem.search.entity.ShortPage;
import com.chem.search.service.ShortPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Description;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 权哥
 * @version 1.0
 * @date 2023/9/14 21:54
 */
@Description("在这里编写你想要在应用程序启动时执行的代码")
@Component
public class MyApplicationRunner implements ApplicationRunner {

    @Autowired
    private ShortPageService shortPageService;

    @Autowired
    private ElasticsearchRestTemplate restTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("加载开始");
        //删除索引
//        restTemplate.indexOps(ShortPage.class).delete();
//        shortPageService.load();
        System.out.println("加载完成");
    }
}
